using System;

namespace Picnic.Spec.Specifications
{
	public class StatementSpec : Specification
	{
		protected override void SpecificationBody()
		{
			Describe<Statement>("class", () =>
			{
				It("should not create new instance without statement text", () =>
				{
					((Action)(() => new Statement(null, () => { })))
						.ShouldRaise<ArgumentException>();

					((Action)(() => new Statement(string.Empty, () => { })))
						.ShouldRaise<ArgumentException>();
				});

				It("should not create new instance without statement body", () =>
					((Action)(() => new Statement("statement text", null)))
						.ShouldRaise<ArgumentException>());
			});

			Describe<Statement>("instance", () =>
			{
				#region Initialization

				var beforeAction1 = new Action(() => { });
				var action1 = new Action(() => { });
				var statement1 = new Statement("Statement1", beforeAction1, action1);

				var beforeAction2= new Action(() => { });
				var action2 = new Action(() => { });
				var statement2 = new Statement("Statement2", beforeAction2, action2);

				var action3 = new Action(() => { });
				var statement3 = new Statement("Statement3", action3);

				#endregion

				It("should have statement text specified on initialization", () =>
				{
					statement1.Text.ShouldEquals("Statement1");
					statement2.Text.ShouldEquals("Statement2");
				});

				It("should have statement body specified on initialization", () =>
				{
					statement1.Body.ShouldEquals(action1);
					statement2.Body.ShouldEquals(action2);
				});

				It("should have before action specified on initialization", () =>
				{
					statement1.Before.ShouldEquals(beforeAction1);
					statement2.Before.ShouldEquals(beforeAction2);
					statement3.Before.ShouldBeNull();
				});
			});
		}
	}
}